package com.zysoft.function;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * **************************************************************
 *
 * @ProjectName: 4g手持机
 * @Package: com.zysoft.function
 * @ClassName: SpecialAdapter
 * @Description: 重写SimpleAdapter 隔行换色
 * @Author: wmf
 * @CreateDate: 2019/10/24 15:28
 * @UpdateDate: 2019/10/24 15:28
 * **************************************************************
 */
public class SpecialAdapter extends SimpleAdapter {
    private int[] colors = new int[] { 0xfff8f8f8, 0xffffffff };

    public SpecialAdapter(Context context, List<Map<String, Object>> items, int resource, String[] from, int[] to) {
        super(context, items, resource, from, to);
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = super.getView(position, convertView, parent);
        int colorPos = position % colors.length;
        view.setBackgroundColor(colors[colorPos]);
        return view;
    }
}
